package com.renzhebiao.lkang.controller;

import java.net.InetAddress;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.renzhebiao.lkang.facade.UserFacade;
import com.renzhebiao.lkang.master.ExecuteResult;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@RestController // 默认类中的方法都会以json的格式返回
@Api(tags = "测试连接相关接口文档")
public class HelloController {

    @Autowired
    private UserFacade userFacade;

    @ApiOperation(value = "用户测试程序是否运行", notes = "程序测试", produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    @GetMapping("/hello")
    // @Need(token = true)
    public ExecuteResult<?> hello() {
        InetAddress ia = null;
        try {
            ia = ia.getLocalHost();

            String localname = ia.getHostName();
            String localip = ia.getHostAddress();
            System.out.println("本机名称是：" + localname);
            System.out.println("本机的ip是 ：" + localip);
            return ExecuteResult.ok(localip);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        // this.userFacade.login();
        return ExecuteResult.ok("hello lkang");
        // return "hello lkang";
    }
}
